//
//  AddViewController.m
//  MyNotes
//
//  Created by chen on 17/3/16.
//  Copyright © 2017年 chen. All rights reserved.
//

#import "AddViewController.h"

@interface AddViewController ()<UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UITextField *contentField;

@end

@implementation AddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"新增备忘";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(SaveButton:)];
    //点击手势
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
    //设置成NO表示当前控件响应后会传播到其他控件上，默认为YES。
    tapGestureRecognizer.cancelsTouchesInView = NO;
    //将触摸事件添加到当前view
    [self.view addGestureRecognizer:tapGestureRecognizer];
    self.contentField.delegate = self;
    // Do any additional setup after loading the view from its nib.
}
-(void)keyboardHide:(UITapGestureRecognizer*)tap{
    [ _contentField endEditing:YES ];
}
- (IBAction)SaveButton:(id)sender {
    NSDictionary *dict = @{@"content":_contentField.text,@"tid":[NSString stringWithFormat:@"%ld",self.tid]};
    [[NSNotificationCenter defaultCenter]postNotificationName:@"GetInformation" object:nil userInfo:dict];
    [self.navigationController popViewControllerAnimated:true];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [_contentField resignFirstResponder];
    return TRUE;
}

@end
